<!DOCTYPE HTML>
<html lang="zh-tw" >
    <!-- Start book python高级 -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>表数据的操作 | python高级</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-emphasize/plugin.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../day14/09.review.html" />
    
    
    <link rel="prev" href="../day14/06.sql_database.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="4.4.4"
        data-chapter-title="表数据的操作"
        data-filepath="day14/08.表数据操作.md"
        data-basepath=".."
        data-revision="Wed Sep 26 2018 22:46:13 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Python高级
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="day11/00.readme.html">
            
                
                    <a href="../day11/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        Python语法高级专题1
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="day11/01.GIL.html">
            
                
                    <a href="../day11/01.GIL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        GIL问题
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="day11/02.copy.html">
            
                
                    <a href="../day11/02.copy.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        赋值-浅拷贝-深拷贝
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="day11/03.import.html">
            
                
                    <a href="../day11/03.import.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        import导入模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="day11/04.review.html">
            
                
                    <a href="../day11/04.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="day12/00.readme.html">
            
                
                    <a href="../day12/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        Python语法高级专题2
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="day12/01.mro.html">
            
                
                    <a href="../day12/01.mro.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        多继承和MRO顺序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="day12/02.property.html">
            
                
                    <a href="../day12/02.property.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        property属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="day12/03.magic.html">
            
                
                    <a href="../day12/03.magic.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        魔法属性和方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="day12/04.with.html">
            
                
                    <a href="../day12/04.with.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        with管理上下文
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="day12/05.review.html">
            
                
                    <a href="../day12/05.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="day13/00.readme.html">
            
                
                    <a href="../day13/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        Python语法之装饰器
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="day13/01.closure.html">
            
                
                    <a href="../day13/01.closure.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        闭包
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="day13/02.decorator.html">
            
                
                    <a href="../day13/02.decorator.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        装饰器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="day13/03.review.html">
            
                
                    <a href="../day13/03.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="day14/00.readme.html">
            
                
                    <a href="../day14/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        MySQL数据库基本操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="day14/01.数据库概述.html">
            
                
                    <a href="../day14/01.数据库概述.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        数据库概述
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="day14/02.数据类型和约束.html">
            
                
                    <a href="../day14/02.数据类型和约束.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        数据完整性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="day14/03.Navicat.html">
            
                
                    <a href="../day14/03.Navicat.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        图形化客户端Navicat
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="day14/04.命令行客户端.html">
            
                
                    <a href="../day14/04.命令行客户端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        命令行客户端SQL的使用
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.1" data-path="day14/05.sql_con.html">
            
                
                    <a href="../day14/05.sql_con.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.1.</b>
                        
                        登录和退出数据库
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.2" data-path="day14/07.sql_table_struct.html">
            
                
                    <a href="../day14/07.sql_table_struct.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.2.</b>
                        
                        表结构的操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.3" data-path="day14/06.sql_database.html">
            
                
                    <a href="../day14/06.sql_database.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.3.</b>
                        
                        数据库的操作
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="4.4.4" data-path="day14/08.表数据操作.html">
            
                
                    <a href="../day14/08.表数据操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.4.</b>
                        
                        表数据的操作
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="day14/09.review.html">
            
                
                    <a href="../day14/09.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        知识总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="day15/00.readme.html">
            
                
                    <a href="../day15/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        MYSQL数据库进阶操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="day15/01.练习.html">
            
                
                    <a href="../day15/01.练习.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        练习强化
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="day15/02.where条件.html">
            
                
                    <a href="../day15/02.where条件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        条件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="day15/03.排序查询.html">
            
                
                    <a href="../day15/03.排序查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="day15/04.分页查询.html">
            
                
                    <a href="../day15/04.分页查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        分页
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="day15/05.聚合函数.html">
            
                
                    <a href="../day15/05.聚合函数.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        聚合函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="day15/06.分组.html">
            
                
                    <a href="../day15/06.分组.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        分组
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="day15/07.连接.html">
            
                
                    <a href="../day15/07.连接.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        连接
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="day15/08.自连接.html">
            
                
                    <a href="../day15/08.自连接.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.</b>
                        
                        自连接
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.9" data-path="day15/09.子查询.html">
            
                
                    <a href="../day15/09.子查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.9.</b>
                        
                        子查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.10" data-path="day15/10.总结.html">
            
                
                    <a href="../day15/10.总结.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.10.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="day16/readme.html">
            
                
                    <a href="../day16/readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        MYSQL数据库编程
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="day16/data.html">
            
                
                    <a href="../day16/data.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        数据准备
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="day16/sql_code.html">
            
                
                    <a href="../day16/sql_code.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        SQL演练
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="day16/dbdesign.html">
            
                
                    <a href="../day16/dbdesign.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        数据库设计
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="day16/pymysql.html">
            
                
                    <a href="../day16/pymysql.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        数据库编程
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="day16/zongjie.html">
            
                
                    <a href="../day16/zongjie.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="day17/00.readme.html">
            
                
                    <a href="../day17/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        MySQL数据库高级用法
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="day17/01.view.html">
            
                
                    <a href="../day17/01.view.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        视图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="day17/02.transaction.html">
            
                
                    <a href="../day17/02.transaction.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        事务
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="day17/03.sql_index.html">
            
                
                    <a href="../day17/03.sql_index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.3.</b>
                        
                        索引
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="day17/04.user.html">
            
                
                    <a href="../day17/04.user.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.</b>
                        
                        用户管理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5" data-path="day17/05.master_slave.html">
            
                
                    <a href="../day17/05.master_slave.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.</b>
                        
                        主从配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6" data-path="day17/06.review.html">
            
                
                    <a href="../day17/06.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" data-path="day18/00.readme.html">
            
                
                    <a href="../day18/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        miniweb框架
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="day18/01.框架是什么.html">
            
                
                    <a href="../day18/01.框架是什么.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        框架概念
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="day18/02.实现框架.html">
            
                
                    <a href="../day18/02.实现框架.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        实现一个简单的框架
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="day18/03.模板.html">
            
                
                    <a href="../day18/03.模板.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        模板替换
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="day18/04.路由.html">
            
                
                    <a href="../day18/04.路由.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                        路由概念
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.5" data-path="day18/05.显示股票数据.html">
            
                
                    <a href="../day18/05.显示股票数据.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.5.</b>
                        
                        股票收藏夹
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.6" data-path="day18/05.review.html">
            
                
                    <a href="../day18/05.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.6.</b>
                        
                        复习
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本書使用 GitBook 釋出
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >python高级</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="44-&#x589E;&#x5220;&#x6539;&#x67E5;curd">4.4 &#x589E;&#x5220;&#x6539;&#x67E5;(curd)</h1>
<p>curd&#x7684;&#x89E3;&#x91CA;: &#x4EE3;&#x8868;&#x521B;&#x5EFA;&#xFF08;Create&#xFF09;&#x3001;&#x66F4;&#x65B0;&#xFF08;Update&#xFF09;&#x3001;&#x8BFB;&#x53D6;&#xFF08;Retrieve/Read&#xFF09;&#x548C;&#x5220;&#x9664;&#xFF08;Delete&#xFF09;</p>
<h3 id="441-&#x67E5;&#x8BE2;&#x57FA;&#x672C;&#x4F7F;&#x7528;">4.4.1 &#x67E5;&#x8BE2;&#x57FA;&#x672C;&#x4F7F;&#x7528;</h3>
<ul>
<li>&#x67E5;&#x8BE2;&#x6240;&#x6709;&#x5217;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">select</span> * <span class="hljs-keyword">from</span> &#x8868;&#x540D;;</span>
&#x4F8B;&#xFF1A;
<span class="hljs-operator"><span class="hljs-keyword">select</span> * <span class="hljs-keyword">from</span> classes;</span>
</code></pre>
<ul>
<li>&#x67E5;&#x8BE2;&#x6307;&#x5B9A;&#x5217;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">select</span> &#x5217;<span class="hljs-number">1</span>,&#x5217;<span class="hljs-number">2</span>,... <span class="hljs-keyword">from</span> &#x8868;&#x540D;;</span>
&#x4F8B;&#xFF1A;
<span class="hljs-operator"><span class="hljs-keyword">select</span> <span class="hljs-keyword">id</span>,<span class="hljs-keyword">name</span> <span class="hljs-keyword">from</span> classes;</span>
</code></pre>
<h3 id="&#x589E;&#x52A0;">4.4.2 &#x589E;&#x52A0; </h3>
<p>INSERT [INTO] &#x8868;&#x540D; [(&#x5B57;&#x6BB5;&#x540D;1,...)] {VALUES | VALUE} ({expr | DEFAULT},...),(...),... </p>
<ul>
<li>&#x8BF4;&#x660E;&#xFF1A;&#x4E3B;&#x952E;&#x5217;&#x662F;&#x81EA;&#x52A8;&#x589E;&#x957F;&#xFF0C;&#x4F46;&#x662F;&#x5728;&#x5168;&#x5217;&#x63D2;&#x5165;&#x65F6;&#x9700;&#x8981;&#x5360;&#x4F4D;&#xFF0C;&#x901A;&#x5E38;&#x4F7F;&#x7528;&#x7A7A;&#x503C;(0&#x6216;&#x8005;null) ; &#x5B57;&#x6BB5;&#x9ED8;&#x8BA4;&#x503C; default &#x6765;&#x5360;&#x4F4D;&#xFF0C;&#x63D2;&#x5165;&#x6210;&#x529F;&#x540E;&#x4EE5;&#x5B9E;&#x9645;&#x6570;&#x636E;&#x4E3A;&#x51C6;</li>
</ul>
<ul>
<li>&#x5168;&#x5217;&#x63D2;&#x5165;&#xFF1A;&#x503C;&#x7684;&#x987A;&#x5E8F;&#x4E0E;&#x8868;&#x7ED3;&#x6784;&#x5B57;&#x6BB5;&#x7684;&#x987A;&#x5E8F;&#x5B8C;&#x5168;&#x4E00;&#x4E00;&#x5BF9;&#x5E94; <blockquote>
<p>&#x6B64;&#x65F6; &#x5B57;&#x6BB5;&#x540D;&#x5217;&#x8868;&#x4E0D;&#x7528;&#x586B;&#x5199;</p>
</blockquote>
</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">insert</span> <span class="hljs-keyword">into</span> &#x8868;&#x540D; <span class="hljs-keyword">values</span> (...)
&#x4F8B;&#xFF1A;
<span class="hljs-keyword">insert</span> <span class="hljs-keyword">into</span> students <span class="hljs-keyword">values</span>(<span class="hljs-number">0</span>,&#x2019;&#x90ED;&#x9756;&#x2018;,<span class="hljs-number">1</span>,<span class="hljs-string">&apos;&#x8499;&#x53E4;&apos;</span>,<span class="hljs-string">&apos;2016-1-2&apos;</span>);</span>
</code></pre>
<ul>
<li>&#x90E8;&#x5206;&#x5217;&#x63D2;&#x5165;&#xFF1A;&#x503C;&#x7684;&#x987A;&#x5E8F;&#x4E0E;&#x7ED9;&#x51FA;&#x7684;&#x5217;&#x987A;&#x5E8F;&#x5BF9;&#x5E94;<blockquote>
<p>&#x6B64;&#x65F6;&#x9700;&#x8981;&#x6839;&#x636E;&#x5B9E;&#x9645;&#x7684;&#x6570;&#x636E;&#x7684;&#x7279;&#x70B9; &#x586B;&#x5199;&#x5BF9;&#x5E94;&#x5B57;&#x6BB5;&#x5217;&#x8868;</p>
</blockquote>
</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">insert</span> <span class="hljs-keyword">into</span> &#x8868;&#x540D; (&#x5217;<span class="hljs-number">1</span>,...) <span class="hljs-keyword">values</span>(&#x503C;<span class="hljs-number">1</span>,...)
&#x4F8B;&#xFF1A;
<span class="hljs-keyword">insert</span> <span class="hljs-keyword">into</span> students(<span class="hljs-keyword">name</span>,hometown,birthday) <span class="hljs-keyword">values</span>(<span class="hljs-string">&apos;&#x9EC4;&#x84C9;&apos;</span>,<span class="hljs-string">&apos;&#x6843;&#x82B1;&#x5C9B;&apos;</span>,<span class="hljs-string">&apos;2016-3-2&apos;</span>);</span>
</code></pre>
<ul>
<li><p>&#x4E0A;&#x9762;&#x7684;&#x8BED;&#x53E5;&#x4E00;&#x6B21;&#x53EF;&#x4EE5;&#x5411;&#x8868;&#x4E2D;&#x63D2;&#x5165;&#x4E00;&#x884C;&#x6570;&#x636E;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x4E00;&#x6B21;&#x6027;&#x63D2;&#x5165;&#x591A;&#x884C;&#x6570;&#x636E;&#xFF0C;&#x8FD9;&#x6837;&#x53EF;&#x4EE5;&#x51CF;&#x5C11;&#x4E0E;&#x6570;&#x636E;&#x5E93;&#x7684;&#x901A;&#x4FE1;</p>
</li>
<li><p>&#x5168;&#x5217;&#x591A;&#x884C;&#x63D2;&#x5165;</p>
</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">insert</span> <span class="hljs-keyword">into</span> &#x8868;&#x540D; <span class="hljs-keyword">values</span>(...),(...)...;</span>
&#x4F8B;&#xFF1A;
<span class="hljs-operator"><span class="hljs-keyword">insert</span> <span class="hljs-keyword">into</span> classes <span class="hljs-keyword">values</span>(<span class="hljs-number">0</span>,<span class="hljs-string">&apos;python1&apos;</span>),(<span class="hljs-number">0</span>,<span class="hljs-string">&apos;python2&apos;</span>);</span>
</code></pre>
<ul>
<li>&#x90E8;&#x5206;&#x5217;&#x591A;&#x884C;&#x63D2;&#x5165; <pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">insert</span> <span class="hljs-keyword">into</span> &#x8868;&#x540D;(&#x5217;<span class="hljs-number">1</span>,...) <span class="hljs-keyword">values</span>(&#x503C;<span class="hljs-number">1</span>,...),(&#x503C;<span class="hljs-number">1</span>,...)...;</span>
&#x4F8B;&#xFF1A;
<span class="hljs-operator"><span class="hljs-keyword">insert</span> <span class="hljs-keyword">into</span> students(<span class="hljs-keyword">name</span>) <span class="hljs-keyword">values</span>(<span class="hljs-string">&apos;&#x6768;&#x5EB7;&apos;</span>),(<span class="hljs-string">&apos;&#x6768;&#x8FC7;&apos;</span>),(<span class="hljs-string">&apos;&#x5C0F;&#x9F99;&#x5973;&apos;</span>);</span>
</code></pre>
</li>
</ul>
<h3 id="443-&#x4FEE;&#x6539;">4.4.3 &#x4FEE;&#x6539;</h3>
<blockquote>
<p>&#x683C;&#x5F0F;: <strong>UPDATE  &#x8868;&#x540D; SET &#x5B57;&#x6BB5;1&#x540D;={expr1|DEFAULT} [,col2={expr2|default}] [where &#x6761;&#x4EF6;&#x5224;&#x65AD;]</strong></p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">update</span> &#x8868;&#x540D; <span class="hljs-keyword">set</span> &#x5217;<span class="hljs-number">1</span>=&#x503C;<span class="hljs-number">1</span>,&#x5217;<span class="hljs-number">2</span>=&#x503C;<span class="hljs-number">2.</span>.. <span class="hljs-keyword">where</span> &#x6761;&#x4EF6;
&#x4F8B;&#xFF1A;
<span class="hljs-keyword">update</span> students <span class="hljs-keyword">set</span> gender=<span class="hljs-number">0</span>,hometown=<span class="hljs-string">&apos;&#x5317;&#x4EAC;&apos;</span> <span class="hljs-keyword">where</span> <span class="hljs-keyword">id</span>=<span class="hljs-number">5</span>;</span>
</code></pre>
<h3 id="&#x5220;&#x9664;">4.4.4 &#x5220;&#x9664; </h3>
<blockquote>
<p><strong>DELETE FROM &#x8868;&#x540D; [where &#x6761;&#x4EF6;&#x5224;&#x65AD;]</strong></p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">delete</span> <span class="hljs-keyword">from</span> &#x8868;&#x540D; <span class="hljs-keyword">where</span> &#x6761;&#x4EF6;
&#x4F8B;&#xFF1A;
<span class="hljs-keyword">delete</span> <span class="hljs-keyword">from</span> students <span class="hljs-keyword">where</span> <span class="hljs-keyword">id</span>=<span class="hljs-number">5</span>;</span>
</code></pre>
<blockquote>
<p>&#x629B;&#x51FA;&#x95EE;&#x9898;: &#x4E0A;&#x9762;&#x7684;&#x64CD;&#x4F5C;&#x79F0;&#x4E4B;&#x4E3A;&#x7269;&#x7406;&#x5220;&#x9664;&#xFF0C;&#x4E00;&#x65E6;&#x5220;&#x9664;&#x5C31;&#x4E0D;&#x5BB9;&#x6613;&#x6062;&#x590D;&#x3002;&#x90A3;&#x4E48;&#x5220;&#x9664;&#x64CD;&#x4F5C;&#x6709;&#x6CA1;&#x6709;&#x4E00;&#x4E2A;&#x7C7B;&#x4F3C;&#x4E8E;&#x56DE;&#x6536;&#x7AD9;&#x4E00;&#x6837;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x80FD;&#x591F;&#x8BA9;&#x7528;&#x6237;&#x9009;&#x62E9;&#x6E05;&#x7A7A;&#x6216;&#x8005;&#x6062;&#x590D;&#x5220;&#x9664;&#x7684;&#x529F;&#x80FD;&#x5462;?</p>
</blockquote>
<pre><code>* &#x5176;&#x5B9E;&#x5220;&#x9664;&#x6587;&#x4EF6;&#x8FDB;&#x5165;&#x56DE;&#x6536;&#x7AD9;&#x7684;&#x672C;&#x8D28;&#x53EA;&#x662F;&#x5728;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x7684;&#x5E2E;&#x52A9;&#x4E0B;&#x5BF9;&#x6587;&#x4EF6;&#x52A0;&#x4E0A;&#x4E86; &#x67D0;&#x4E2A;&#x6807;&#x8BB0;&#xFF0C;&#x8D44;&#x6E90;&#x7BA1;&#x7406;&#x5668;&#x4E2D;&#x5BF9;&#x542B;&#x6709;&#x8FD9;&#x79CD;&#x6807;&#x8BB0;&#x7684;&#x6587;&#x4EF6;&#x4E0D;&#x4F1A;&#x663E;&#x793A;&#x3002;&#x5F53;&#x4ECE;&#x56DE;&#x6536;&#x7AD9;&#x6062;&#x590D;&#x7684;&#x65F6;&#x5019;&#x53EA;&#x662F;&#x79FB;&#x9664;&#x4E86;&#x52A0;&#x4E0A;&#x7684;&#x6807;&#x8BB0;&#x800C;&#x5DF2;&#x3002;
</code></pre><ul>
<li>&#x903B;&#x8F91;&#x5220;&#x9664;&#xFF0C;&#x672C;&#x8D28;&#x5C31;&#x662F;&#x4FEE;&#x6539;&#x64CD;&#x4F5C;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">update</span> students <span class="hljs-keyword">set</span> isdelete=<span class="hljs-number">1</span> <span class="hljs-keyword">where</span> <span class="hljs-keyword">id</span>=<span class="hljs-number">1</span>;</span>
</code></pre>
<h3 id="445-&#x603B;&#x7ED3;">4.4.5 &#x603B;&#x7ED3;</h3>
<p>&#x67E5;&#x8BE2;&#x53E5;&#x5F0F; select &#x5B57;&#x6BB5;&#x540D;&#x79F0; [as &#x522B;&#x540D;] from &#x8868;;
&#x66F4;&#x65B0;&#x53E5;&#x5F0F; update &#x8868;&#x540D; set &#x5B57;&#x6BB5;&#x540D;=&#x65B0;&#x503C; where &#x6761;&#x4EF6;;
&#x63D2;&#x5165;&#x53E5;&#x5F0F; insert into &#x8868;&#x540D; [&#x5168;&#x5217;&#x63D2;&#x4E0D;&#x586B;&#x5B57;&#x6BB5;&#x540D;] values ()[,(),()]
&#x5220;&#x9664;&#x53E5;&#x5F0F; delete from &#x8868;&#x540D; where &#x6761;&#x4EF6;&#xFF1B;</p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../day14/06.sql_database.html" class="navigation navigation-prev " aria-label="Previous page: 数据库的操作"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../day14/09.review.html" class="navigation navigation-next " aria-label="Next page: 知识总结"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"toggle-chapters":{},"splitter":{},"emphasize":{},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book python高级 -->
</html>
